{% extends 'base.html' %}

{% block content %}

    <div class="wrapper wrapper-content animated fadeIn">
        <div class="row">
            <div class="col-sm-12">
                <div class="ibox float-e-margins" id="all">
                    <div class="ibox-title">
                        <h5> 项目信息列表</h5>
                        <div class="ibox-tools">
                            <a>
                                <i class="fa fa-plus" data-toggle="modal" data-target="#addModal"></i>
                            </a>
                            <a>
                                <i class="fa fa-minus" data-toggle="modal" data-target="#deleteModal"></i>
                            </a>
                            <a class="collapse-link">
                                <i class="fa fa-chevron-up"></i>
                            </a>
                        </div>
                    </div>

                    <div class="ibox-content">
                        {# 新增项目的弹框 #}
                        <div class="modal inmodal fade" id="addModal" tabindex="-1" role="dialog"
                             aria-labelledby="addModalLabel"
                             aria-hidden="true">
                            <div class="modal-dialog">
                                <div class="modal-content animated fadeIn">
                                    <div class="modal-header">
                                        <button type="button" class="close" data-dismiss="modal"><span
                                                aria-hidden="true">×</span><span class="sr-only">Close</span></button>
                                        <i class="fa fa-paypal modal-icon"></i>
                                        <h4 class="modal-title">项目配置</h4>
{#                                        <small>配置项目相关信息，以供crontab使用</small>#}
                                    </div>
                                    <div class="modal-body">
                                        <form class="form-horizontal">
                                            <div class="form-group">
                                                <label class="col-lg-2 control-label"><span style="color: red;">*</span>项目名</label>
                                                <div class="col-lg-10">
                                                    <input type="text" placeholder="ugm"
                                                           class="form-control" id="project_name">
                                                </div>
                                            </div>
                                            <div class="form-group">
                                                <label class="col-lg-2 control-label"><span style="color: red;">*</span>本地路径</label>
                                                <div class="col-lg-10">
                                                    <input type="text" placeholder="/home/hongjianzhu/ugm/"
                                                           class="form-control" id="project_path">
                                                    <span class="help-block m-b-none" style="color: red;">以'/'结尾，不包含项目名</span>
                                                </div>
                                            </div>
                                            <div class="form-group">
                                                <label class="col-lg-2 control-label"><span style="color: red;">*</span>SVN</label>
                                                <div class="col-lg-10">
                                                    <select class="form-control" id="svn_select">
                                                        {% for minion in svn_objs %}
                                                            <option value={{ minion.id }}>{{ minion.repo }} &nbsp;&nbsp;&nbsp;&nbsp; {{ minion.local_path }}</option>
                                                        {% endfor %}
                                                    </select>
                                                </div>
                                            </div>
                                        </form>
                                    </div>
                                    <div class="modal-footer">
                                        <button type="button" class="btn btn-white" data-dismiss="modal">关闭</button>
                                        <button type="button" class="btn btn-primary" id="addProjectButton">保存</button>
                                    </div>
                                </div>
                            </div>
                        </div>
                        {# 新增项目的弹框--end #}

                        {# 删除项目的弹框 #}
                        <div class="modal inmodal fade" id="deleteModal" tabindex="-1" role="dialog"
                             aria-labelledby="deleteModalLabel"
                             aria-hidden="true">
                            <div class="modal-dialog">
                                <div class="modal-content animated fadeIn">
                                    <div class="modal-header">
                                        <button type="button" class="close" data-dismiss="modal"><span
                                                aria-hidden="true">×</span><span class="sr-only">Close</span></button>
                                        <i class="fa fa-warning modal-icon" style="color: red"></i>
                                        <h4 class="modal-title text-danger">确定删除所选项目？</h4>
                                        <br>
                                        <small class="text-warning">请小心操作！</small>
                                    </div>
                                    <div class="modal-footer">
                                        <button type="button" class="btn btn-white" data-dismiss="modal">关闭</button>
                                        <button type="button" class="btn btn-danger" id="deleteProjectButton">删除</button>
                                    </div>
                                </div>
                            </div>
                        </div>
                        {# 删除项目的弹框--end #}

                        <form id="asset_form">
                            <table class="table table-striped table-bordered table-hover " id="editable"
                                   name="editable">
                                <thead>
                                <tr>
                                    <th class="text-center">
                                        <input id="checkall" type="checkbox" class="i-checks" name="checkall"
                                               value="checkall" data-editable='false' onclick="check_all('asset_form')">
                                    </th>
                                    <th class="text-center"> 项目名</th>
                                    <th class="text-center"> 本地路径</th>
                                    <th class="text-center"> SVN URL</th>
                                    <th class="text-center"> 创建者</th>
                                    <th class="text-center"> 创建时间</th>
                                </tr>
                                </thead>
                                <tbody>
                                {% for project in project_list %}
                                    <tr class="gradeX">
                                        <td class="text-center" name="id" value="{{ project.id }}"
                                            data-editable='false'>
                                            <input name="id" value="{{ project.id }}" type="checkbox" class="i-checks">
                                        </td>
                                        <td class="text-center">{{ project.name }}</td>
                                        <td class="text-center">{{ project.path }}</td>
                                        <td class="text-center">{{ project.svn_url }}</td>
                                        <td class="text-center">{{ project.creator_name }}</td>
                                        <td class="text-center"> {{ project.create_time|date:"Y-m-d H:i:s" }} </td>
                                    </tr>
                                {% endfor %}
                                </tbody>
                            </table>
                        </form>
                    </div>
                </div>
            </div>
        </div>
    </div>

    <script src="/static/js/custom/project.js"></script>
{% endblock %}

